﻿@page "/post"
@attribute [ReuseTabsPage(Title = "岗位权限")]


@using ZLJ.Application.Share.Post


@* @attribute [ReuseTabsPageTitle("员工岗位权限")] *@
@attribute [Authorize(PermissionNames.AdministratorBaseInfoPost)]
@inherits ListBaseComponent< PostDto, int, PagedAndSortedResultRequest< PagedPostResultRequestDto>>

<Flex Gap="small" Vertical Justify="space-between">
     <Flex Justify="space-between">
         @* 左侧 *@
         <Flex Gap="small">
             @if (createIsGranted)
            {
                <Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Plus" OnClick="ShowCreateDialog">新增</Button>
            }
            @if (deleteIsGranted)
            {
                <Popconfirm Title="确定删除已选择的项吗?"
                            OnConfirm="BtnDeleteClick">
                    <Button Type="@ButtonType.Default" Icon="@IconType.Outline.Clear" Loading=isDeleting Danger="true" Disabled="@ShouldDisableDelete">删除</Button>
                </Popconfirm>
            }
            <Button OnClick="AddRandomData" Disabled=sj>新增一堆随机数据</Button>
        </Flex>
        @* 右侧 *@
        <Flex Gap="small">
            <TreeSelectOu Style="min-width:10rem;" AllowClear Value="@GetAllInput.Filter.OuCode" ValueChanged="OnOuChanged" @ref=ou Disabled=IsLoading />
             <RadioGroup TValue="bool?" @bind-Value="@GetAllInput.Filter.IsStatic" OnChange="BtnSearchClick" Disabled=IsLoading>
                 <Radio TValue="bool?" RadioButton="true" Value="@(default(bool?))">全部</Radio>
                 <Radio TValue="bool?" RadioButton="true" Value="@(true)">预设</Radio>
                 <Radio TValue="bool?" RadioButton="true" Value="@(false)">非预设</Radio>
             </RadioGroup>
             @*Search组件有问题，设置宽度会错位 *@
             <div style="width:15rem;">
                 <Search Placeholder="请输入关键字..." @bind-Value="@Keywords" OnChange=BtnSearchClick AllowClear="true" ClassicSearchIcon="true" Disabled=IsLoading />
             </div>
             <Tooltip Title="清空条件">
                 <Button Type="@ButtonType.Default" Icon="@IconType.Outline.Clear" OnClick="BtnClearFilterClick" Disabled=IsLoading></Button>
             </Tooltip>
             <Tooltip Title="刷新">
                 <Button Type="@ButtonType.Default" Icon="@IconType.Outline.Reload" OnClick="BtnRefreshClick" Disabled=IsLoading></Button>
             </Tooltip>
         </Flex>
     </Flex>

     <Table @ref="table"
            TItem="PostDto"
            Total="TotalCount"
            @bind-SelectedRows="SelectedItems"
            OnChange="OnQuery"
            DataSource="Items"
            PageIndex="PageIndex"
            PageSize="PageSize"
            Loading="IsLoading"
            HidePagination=false
            RowClassName="@(r=>r.RowIndex%2==0?"even":"odd")"
            RemoteDataSource="true"
            RowKey="x=>x.Id"
            OnRow="OnRow"
            Size="TableSize.Small"
            Bordered="true"
           ScrollY="71.5vh">

         <Selection Key="@(context.Id.ToString())" />
         <Column TData="PostDto" Title="行号" Width="60">
             @(PageSize * (PageIndex - 1) + Items.IndexOf(context) + 1)
         </Column>
         <PropertyColumn Property="c=>c.DisplayName" Sortable="true" DefaultSortOrder="SortDirection.Ascending" ShowSorterTooltip="false" Width="300" />
         @* <PropertyColumn Property="c=>c.Name" /> *@
         <PropertyColumn Property="c=>c.IsStatic" Width="80">
             <Switch @bind-Value="@context.IsStatic" Size="@InputSize.Small" Disabled="true"></Switch>
         </PropertyColumn>
         <PropertyColumn Property="c=>c.Description" />
         <ActionColumn Title="操作" Width="200">
             @* ButtonGroup设置Size好像没啥卵用 *@
             <ButtonGroup Size="@ButtonSize.Small">
                 <Button Size="@ButtonSize.Small" Type="@ButtonType.Primary" OnClick="x=>OnDetail(context)">详情</Button>
                 @if (updateIsGranted)
                {
                    <Button Size="@ButtonSize.Small" OnClick="x=>OnEdit(context)">修改</Button>
                }
                @if (deleteIsGranted)
                {
                    <Popconfirm Title="确定删除此项吗?"
                                OnConfirm="()=>BtnDeleteItemClick(context)">
                        <Button Size="@ButtonSize.Small" Danger="true" Loading=@context.ExtensionData.IsDeleting>删除</Button>
                    </Popconfirm>
                }
            </ButtonGroup>
        </ActionColumn>
    </Table>

</Flex>

@* <AbpCreateDialog TAppService="IPostAppService" TEntityDto="PostDto" TPrimaryKey="int"
                 TGetAllInput="PagedAndSortedResultRequest<PagedPostResultRequestDto>"
                 TCreateInput="CreatePostDto" TUpdateInput="PostEditDto" TCreateComponent="Create"
>

</AbpCreateDialog>
 *@

@{
    RenderFragment renderFragment =@<Template>
        <SectionOutlet SectionName=@(FuncName + "-create-btns") />
        <Button OnClick="CloseDialog">关闭</Button>
    </Template>;
}
<Modal DestroyOnClose="true" Footer="renderFragment" @bind-Visible="isCreateDialogVisible" Draggable="true" Width=@("40vw")>
    <TitleTemplate>
        <Icon Type="plus" Theme="outline" />
        新增@(FuncName)
    </TitleTemplate>

    <ChildContent>
        <SectionOutlet SectionName=@(FuncName + "-create-body") />
        <Create OnAddEnd="OnAddEnd" />
    </ChildContent>
</Modal>

@{
    RenderFragment renderFragment1 =@<Template>
        <SectionOutlet SectionName=@(FuncName + "-detail-update-btns") />
        <Button OnClick="x=>isShowDetailUpdate=false">关闭</Button>
    </Template>;
}
<Modal DestroyOnClose="true" Footer="renderFragment1" @bind-Visible="isShowDetailUpdate" Draggable="true" Width=@("40vw")>
    <TitleTemplate>
        <SectionOutlet SectionName=@(FuncName + "-detail-update-title") />
    </TitleTemplate>
    <ChildContent>
        <SectionOutlet SectionName=@(FuncName + "-detail-update-body") />
        <DetailUpdate Id=detailUpdateId IsEdit=isEdit OnDeleted=OnDetailUpdate OnUpdated=OnDetailUpdate />
    </ChildContent>
</Modal>